﻿/***************************************************************************
 *    
 *      Copyright (c) 2009,2010 KaiTrade LLC (Delaware)
 *                     All Rights Reserved Worldwide
 *
 * STRICTLY PROPRIETARY and CONFIDENTIAL
 *
 * WARNING:  This file is the confidential property of KaiTrade LLC For
 * use only by those with the express written permission and license from
 * KaiTrade LLC.  Unauthorized reproduction, distribution, use or disclosure 
 * of this file or any program (or document) is prohibited. 
 * 
 ***************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace K2AlgoSet
{
    public class K2ExtendedAlgo : KaiTrade.Interfaces.KTAPlugin
    {
        /// <summary>
        /// Logger
        /// </summary>
        public log4net.ILog m_Log = log4net.LogManager.GetLogger("Kaitrade");

        public K2ExtendedAlgo()
        {
           

        }

        private void addExpressions()
        {
            try
            {
                //Factory.Instance().AppFacade.Factory.GetAlgoManager().AddInstanceFactory(KaiTrade.Interfaces.AlgoType.StatExpression, null);
            }
            catch (Exception myE)
            {
                m_Log.Error("addExpressions", myE);
            }
        }



        #region KTAPlugin Members

        public System.Windows.Forms.Control CreateUserControl(string myName)
        {
            return null;
        }

        public KaiTrade.Interfaces.K2Control CreateK2Control(string name)
        {
            return null;
        }

        /// <summary>
        /// get a list of the controls we support
        /// </summary>
        /// <returns></returns>
        public List<string> GetUserControlName()
        {
            List<string> myNames = new List<string>();
           
            return myNames;
        }

        public string Name
        {
            get { return "K2ExtendedAlgo"; }
        }
        /// <summary>
        /// Get the group name that the control belongs to
        /// </summary>
        public string GroupName { get { return "Main"; } }

        public string VendorName { get { return "KaiTrade LLC"; } }

        /// <summary>
        /// get the controls ID - used to permission
        /// </summary>
        public string ID
        { get { return "AAAABBBB"; } }


      

        public void SetFacade(KaiTrade.Interfaces.Facade myFacade)
        {
            Factory.Instance().AppFacade = myFacade;
        }
        /// <summary>
        /// Set the plugin user context this allows the plugin to identify the current user
        /// </summary>
        /// <param name="myUserContext"></param>
        public void SetUserContext(KaiTrade.Interfaces.User user)
        {
        }

        public void Start(string myState)
        {
            try
            {
                // THis plugin does not expose any user interface, it does provide various algo extensions to KaiTrade
                Factory.Instance().AppFacade.Factory.GetAlgoManager().AddInstanceFactory(KaiTrade.Interfaces.AlgoType.StatExpression, ExpressionFactory.Instance());
                Factory.Instance().AppFacade.Factory.GetAlgoManager().AddInstanceFactory(KaiTrade.Interfaces.AlgoType.PatternMatcher, PatternMatchFactory.Instance());
                Factory.Instance().AppFacade.Factory.GetAlgoManager().AddInstanceFactory(KaiTrade.Interfaces.AlgoType.ORStrategy, ORAlgoFactory.Instance());
                
            }
            catch (Exception myE)
            {
                m_Log.Error("Start", myE);
            }
        }

        public void Stop()
        {
            try
            {
               
            }
            catch (Exception myE)
            {

            }
        }

       

        public System.Drawing.Image GetControlImage(string myName)
        {
            return null;
        }

       


        #endregion

       
    }
}
